package com.ruoyi.civil.service.impl;

import java.util.List;

import com.ruoyi.civil.domain.RoadInfo;
import com.ruoyi.civil.service.IRoadInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.civil.mapper.CivilEnginneeringRegularCheckMapper;
import com.ruoyi.civil.domain.CivilEnginneeringRegularCheck;
import com.ruoyi.civil.service.ICivilEnginneeringRegularCheckService;

/**
 * 土建结构定期检查Service业务层处理
 *
 * @author 小赵
 * @date 2022-04-25
 */
@Service
public class CivilEnginneeringRegularCheckServiceImpl implements ICivilEnginneeringRegularCheckService
{
    @Autowired
    private CivilEnginneeringRegularCheckMapper civilEnginneeringRegularCheckMapper;
    @Autowired
    private IRoadInfoService roadInfoService;

    @Override
    public CivilEnginneeringRegularCheck selectCivilEnginneeringRegularCheckByRegularCheckId(Long regularCheckId)
    {
        return civilEnginneeringRegularCheckMapper.selectCivilEnginneeringRegularCheckByRegularCheckId(regularCheckId);
    }


    @Override
    public List<CivilEnginneeringRegularCheck> selectCivilEnginneeringRegularCheckList(CivilEnginneeringRegularCheck civilEnginneeringRegularCheck)
    {
        return civilEnginneeringRegularCheckMapper.selectCivilEnginneeringRegularCheckList(civilEnginneeringRegularCheck);
    }


    @Override
    public int insertCivilEnginneeringRegularCheck(CivilEnginneeringRegularCheck civilEnginneeringRegularCheck)
    {
        String roadName=civilEnginneeringRegularCheck.getRoadName();
        System.out.println("============================"+roadName);
        RoadInfo roadInfo=roadInfoService.checkByRoadName(roadName);
        System.out.println("======================="+roadInfo);
        if(roadInfo==null){
             return 0;
        }else{
             return civilEnginneeringRegularCheckMapper.insertCivilEnginneeringRegularCheck(civilEnginneeringRegularCheck);
        }

    }


    @Override
    public int updateCivilEnginneeringRegularCheck(CivilEnginneeringRegularCheck civilEnginneeringRegularCheck)
    {
        return civilEnginneeringRegularCheckMapper.updateCivilEnginneeringRegularCheck(civilEnginneeringRegularCheck);
    }


    @Override
    public int deleteCivilEnginneeringRegularCheckByRegularCheckIds(Long[] regularCheckIds)
    {
        return civilEnginneeringRegularCheckMapper.deleteCivilEnginneeringRegularCheckByRegularCheckIds(regularCheckIds);
    }


    @Override
    public int deleteCivilEnginneeringRegularCheckByRegularCheckId(Long regularCheckId)
    {
        return civilEnginneeringRegularCheckMapper.deleteCivilEnginneeringRegularCheckByRegularCheckId(regularCheckId);
    }
}
